<template>
  <div>
    <div v-show="!readonly" class='com-editor' id="product-edit">
    </div>
    <div v-if="readonly" class='com-editor ft14'><div v-html="getInfo"></div></div>
    </div>
</template>
<script>
export default {
  props:['readonly','info'],
  components: {},
  name: "",
  data() {
    return {
      editor:null,
      editorContent:""
    };
  },
  computed:{
    getInfo(){
      return this.info
    },
  },
  watch:{
    info(){
      if(this.editor)this.editor.txt.html(this.info)
    }
  },
  methods: {
    init(){
      var E = window.wangEditor
      this.editor = new E('#product-edit')
      this.editor.customConfig.uploadFileName = 'file'
      this.editor.customConfig.onchange = (html) => {
         this.editorContent = html
          this.$emit("getDetail",this.editorContent)
      }
      //this.editor.customConfig.uploadImgServer = picPATH //配置服务地址
      this.editor.customConfig.uploadImgServer = PATH+"Common/getPicAddressList.do" //配置服务地址
      this.editor.create()
      this.editor.txt.html(this.$store.state.editors.product.content)
      this.$store.state.editors.product.obj=this.editor


    }

  },
  created() {
    this.$nextTick(()=>{
      this.init()
    })
  }
};
</script>
<style lang="scss" scoped>
.com-editor {
  margin-top: 10px;
  margin-left: 20px;
}
</style>